<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第一题</title>
</head>

<body>
    <script>
        function getRandom() {
            let random = Math.floor(Math.random() * 7)
            for (let i = 0; i < 3; i++) {
                let num = +prompt(`请输入0到7之间的任意整数，您一共有三次机会这个是第${i + 1}次`)
                if (num > random) {
                    alert('输入的数大了')
                    if (i == 2) {
                        alert(`三次机会已用完，您还没回答正确，，正确答案为:${random}`)
                    }
                }
                if (num < random) {
                    alert('输入的数小了')
                    if (i == 2) {
                        alert(`三次机会已用完，您还没回答正确，，正确答案为:${random}`)
                    }
                }
                if (num == random) {
                    alert('恭喜您回答正确')
                    return
                }
            }
        }
        getRandom()
    </script>
</body>

</html>